package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.AlertRuleDto;
import com.zzyl.dto.BedDto;
import com.zzyl.service.AlertRuleService;
import com.zzyl.vo.AlertRuleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/alert-rule")
@Api(tags = "智能规则管理相关接口")
public class AlertRuleController extends BaseController{

    @Autowired
    private AlertRuleService alertRuleService;

    @ApiOperation("新增规则")
    @PostMapping("/create")
    public ResponseResult createBed(@RequestBody AlertRuleDto alertRuleDto){
        alertRuleService.create(alertRuleDto);
        return success();
    }

    @ApiOperation("查询规则")
    @GetMapping("/get-page")
    public ResponseResult<PageResponse<AlertRuleVo>> getPage(Integer pageNum, Integer pageSize, String alertRuleName, String functionName, String productKey){
        PageResponse<AlertRuleVo> list = alertRuleService.getPage(pageNum,pageSize,alertRuleName,functionName,productKey);
        return ResponseResult.success(list);
    }

    @ApiOperation("更新告警规则")
    @PutMapping("/update/{id}")
    public ResponseResult updateAlertRule(@RequestBody AlertRuleDto alertRuleDto,@PathVariable Long id){
        alertRuleDto.setId(id);
        alertRuleService.updateAlertRule(alertRuleDto);
        return success();
    }

    @ApiOperation("删除告警规则")
    @DeleteMapping("/delete/{id}")
    public ResponseResult deleteAlertRule(@PathVariable Long id){
        alertRuleService.deleteAlertRule(id);
        return success();
    }
}



















